#include "stdafx.h"
#include "Fakes/FakeD3D10Device.h"
#include "Fakes/FakeD3D10Texture1D.h"

DESCRIPTION_10_TEST_SUITE_CTOR(Texture1DDescription, (DXGI_FORMAT_R8G8B8A8_UINT, 256))

BOOST_FIXTURE_TEST_CASE(Default, TestTexture1DDescription)
{
	BOOST_REQUIRE_EQUAL(256, m_desc.Width);
	BOOST_REQUIRE_EQUAL(0, m_desc.MipLevels);
	BOOST_REQUIRE_EQUAL(1, m_desc.ArraySize);
	BOOST_REQUIRE_EQUAL(DXGI_FORMAT_R8G8B8A8_UINT, m_desc.Format);
	BOOST_REQUIRE_EQUAL(D3D10_USAGE_DEFAULT, m_desc.Usage);
	BOOST_REQUIRE_EQUAL(D3D10_BIND_SHADER_RESOURCE, m_desc.BindFlags);
	BOOST_REQUIRE_EQUAL(0, m_desc.CPUAccessFlags);
	BOOST_REQUIRE_EQUAL(0, m_desc.MiscFlags);
}

#define TEXTURE1D_DESCRIPTION_TEST_CASE(type_, name_, value_) \
	DESCRIPTION_10_TEST_CASE(type_, name_, value_, Texture1DDescription)

TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, ArraySize, 2)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, MipLevels, 2)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, BindFlags, D3D10_BIND_STREAM_OUTPUT)
TEXTURE1D_DESCRIPTION_TEST_CASE(D3D10_USAGE, Usage, D3D10_USAGE_DYNAMIC)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, CPUAccessFlags, D3D10_CPU_ACCESS_READ)
TEXTURE1D_DESCRIPTION_TEST_CASE(UINT, MiscFlags, D3D10_RESOURCE_MISC_SHARED)

BOOST_FIXTURE_TEST_CASE(CreateNoData, TestTexture1DDescription)
{
	FakeD3D10Device device;
	FakeD3D10Texture1D texture;
	device.CreateTexture1DFakeResult = &texture;
	device.CreateTexture1DFakeHResult = S_OK;
	ID3D10Texture1D *result = m_desc.Create(&device);
	BOOST_REQUIRE(device.CreateTexture1DCalled);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateTexture1DLastDesc);
	BOOST_REQUIRE_EQUAL(&texture, result);
}

BOOST_FIXTURE_TEST_CASE(CreateWithData, TestTexture1DDescription)
{
	FakeD3D10Device device;
	FakeD3D10Texture1D texture;
	device.CreateTexture1DFakeResult = &texture;
	device.CreateTexture1DFakeHResult = S_OK;
	int contents = 1964;
	rt::D3D10::SubResourceData data(&contents);
	ID3D10Texture1D *result = m_desc.Create(&device, &data);
	BOOST_REQUIRE(device.CreateTexture1DCalled);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateTexture1DLastDesc);
	BOOST_REQUIRE_EQUAL(&data, device.CreateTexture1DLastData);
	BOOST_REQUIRE_EQUAL(&texture, result);
}

BOOST_AUTO_TEST_SUITE_END()
